home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Performance Co-Pilot 1.3
/
SGI Performance Co-Pilot 1.3.iso
/
dist
/
pcp.idb
/
usr
/
pcp
/
lib
/
pmgadgets-args.z
/
pmgadgets-args
Wrap
Text File
|
1997-04-03
|
5KB
|
231 lines
#
# Copyright (c) 1994 Silicon Graphics, Inc.
# ALL RIGHTS RESERVED.
#
# U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND
# Use, duplication or disclosure by the Government is subject to
# restrictions as set forth in FAR 52.227.19(c)(2) or subparagraph
# (c)(1)(ii) of the Rights in Technical Data and Computer Software clause
# at DFARS 252.227-7013 and/or similar or successor clauses in the FAR,
# or the DOD or NASA FAR Supplement. Contractor/manufacturer is Silicon
# Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
#
# THIS SOFTWARE CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION OF
# SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, DISTRIBUTION, OR
# DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN
# PERMISSION OF SILICON GRAPHICS, INC.
# /
#
# $Id: pmgadgets-args,v 2.3 1997/03/26 02:52:57 kenmcd Exp $
#
prog=`basename $0`
#
# Standard usage and command-line argument parsing for pmgadgets front ends.
# This file should be included by pmgadgets front end scripts to present a
# consistent interface. See pmgadgets(1) for more information.
#
#
# The front end scripts should call _pmgadgets_usage after their own usage
# information in a subroutine called _usage. The _usage subroutine may be
# called by either _pmgadgets_usage or _pmgadgets_args.
#
_pmgadgets_usage()
{
echo '
-h host metrics source is PMCD on host
-n namespace use an alternative PMNS
-t interval change the default update interval
-delta interval change the default update interval
-z set reporting timezone to local time for host
from -h
-Z timezone set reporting timezone
-zoom factor make the gadgets bigger by a factor of 1, 2, 3 or 4
-infofont fontname use fontname for info dialogs text
-defaultfont fontname use fontname by default for label gadgets
-display display-string
-title title-string
-geometry geometry-string
-name name-string
-xrm resource [-xrm ..]'
}
#
# One of the first actions of a front end script should be to call
# _pmgadgets_args. It sets the following variables:
#
# host the host specified with -h.
# interval the update interval specified by the user, 0 indicates it
# was not specified. The caller must pass this on to pmgadgets,
# unlike $host which is included in $args.
# args The list of args that pmgadgets will comprehend and use.
# otherArgs The arguments pmgadgets will not understand and should be
# handled by the front end script.
# titleArg The title the user prefers. If empty, the title should be
# provided by the front end script.
# prog The name of the program.
# namespace The namespace (including the flag) if specified, else empty
# eg "-n foo"
#
_pmgadgets_args()
{
host=""
args=""
otherArgs=""
titleArg=""
namespace=""
interval=0
while [ $# -gt 0 ]
do
case $1
in
-g*|-d*|-fg|-bg|-name|-xrm)
# assume an X11 argument
if [ $# -lt 2 ]
then
echo "$prog: $1 requires one argument"
_usage
exit 1
fi
args="$args $1 '$2'"
shift
;;
-title)
# assume an X11 argument
if [ $# -lt 2 ]
then
echo "$prog: $1 requires one argument"
_usage
exit 1
fi
titleArg="$2"
shift
;;
-D|-Z|-delta|-zoom|-infofont|-defaultfont)
if [ $# -lt 2 ]
then
echo "$prog: $1 requires one argument"
_usage
exit 1
fi
args="$args $1 '$2'"
shift
;;
-D*|-Z*|-z)
args="$args $1"
;;
-h)
if [ $# -lt 2 ]
then
echo "$prog: $1 requires one argument"
_usage
exit 1
fi
host=$2
args="$args -h $2"
shift
;;
-t)
if [ $# -lt 2 ]
then
echo "$prog: $1 requires one argument"
_usage
exit 1
fi
interval=$2
shift
;;
-n)
if [ $# -lt 2 ]
then
echo "$prog: $1 requires one argument"
_usage
exit 1
fi
namespace="-n $2"
args="$args -n $2"
shift
;;
*)
otherArgs="$otherArgs $1"
;;
esac
shift
done
}
# standard fatal error reporting
# Usage: _pmgadgets_error message goes in here
# _pmgadgets_error -f file
#
_pmgadgets_error()
{
_pmgadgets_note Error error $*
}
# standard warning
# Usage: _pmgadgets_warning message goes in here
# _pmgadgets_warning -f file
#
_pmgadgets_warning()
{
_pmgadgets_note Warning warning $*
}
# standard info
# Usage: _pmgadgets_info message goes in here
# _pmgadgets_info -f file
#
_pmgadgets_info()
{
_pmgadgets_note Info info $*
}
# generic notifier
# Usage: _pmgadgets_note tag icon args ...
#
_pmgadgets_note()
{
tag=$1; shift
icon=$1; shift
button=""
[ $tag = Error ] && button="-B Quit"
if [ -z "$DISPLAY" -o "${PCP_USE_STDERR+yes}" = yes ]
then
if [ $# -eq 2 -a "X$1" = X-f ]
then
echo "$prog: $tag: ..."
cat $2
else
echo "$prog: $tag: $*"
fi
else
if [ $# -eq 2 -a "X$1" = X-f ]
then
/usr/bin/X11/xconfirm -icon $icon -file $2 -useslider -header "$tag $prog" $button >/dev/null 2>&1
else
/usr/bin/X11/xconfirm -icon $icon -t "$*" -noframe -header "$tag $prog" $button >/dev/null 2>&1
fi
fi
[ $tag = Error ] && exit 1
}